package org.com.Controller;


import Entity.Comment;
import org.com.Service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 277
 * @since 2025-10-16
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private ICommentService commentService;

    @PostMapping("/save")
    public boolean save(@RequestBody Comment comment) {
        return commentService.save(comment);
    }

    @GetMapping("/list/{postId}")
    public List<Comment> list(@PathVariable Integer postId) {
        return commentService.lambdaQuery().eq(Comment::getPostid, postId)
                .orderByDesc(Comment::getCreateTime)
                .list();
    }
}
